package com.bear.fastrepair.base

import android.app.Application
import com.amap.api.location.AMapLocationClient
import com.bear.fastrepair.utils.UM_APP_KEY
import com.bear.fastrepair.utils.UM_APP_MASTER_SECRET
import com.umeng.commonsdk.UMConfigure
import com.umeng.umcrash.UMCrash
import java.lang.ref.SoftReference

class BearApplication : Application() {
    private val channel = "manual"

    override fun onCreate() {
        super.onCreate()
        instance = SoftReference(this)
        UMConfigure.setLogEnabled(true)
        UMConfigure.preInit(this, UM_APP_KEY, channel)
        UMConfigure.init(
            this,
            UM_APP_KEY,
            channel,
            UMConfigure.DEVICE_TYPE_PHONE,
            UM_APP_MASTER_SECRET
        )
        UMCrash.init(this, UM_APP_KEY, channel)

        AMapLocationClient.updatePrivacyShow(this, true, true);
        AMapLocationClient.updatePrivacyAgree(this, true);
    }

    companion object {
        private lateinit var instance: SoftReference<Application>
        fun getApplication(): Application? {
            return instance.get()
        }
    }

}